/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GenerateSettingPanel.java
 *
 * Created on 2011-4-25, 14:01:09
 */
package com.iduxs.collect.frame.system;

import com.iduxs.collect.utils.Utility;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class GenerateSettingPanel extends javax.swing.JPanel {

    /** Creates new form GenerateSettingPanel */
    public GenerateSettingPanel() {
        initComponents();
        init();
    }

    private void init() {
        GenerateSetting gs = new GenerateSetting();
        try {
            Utility.readXMLFile("GenerateSetting.xml", gs);
            chapterContextText.setText(gs.getChapterContext());
            coverPathText.setText(gs.getCoverPath());
            generateContextPageText.setText(gs.getGenerateContextPage());
            generateFulltextText.setText(gs.getGenerateFulltext());
            generateIndexPageText.setText(gs.getGenerateIndexPage());
            generateOpfText.setText(gs.getGenerateOpf());
            imagePathText.setText(gs.getImagePath());
            nextPageText.setText(gs.getNextPage());
            prevPageText.setText(gs.getPrevPage());
            remoteChapterContextText.setText(gs.getRemoteChapterContext());
            remoteContextPageText.setText(gs.getRemoteContextPage());
            remoteCoverPathText.setText(gs.getRemoteCoverPath());
            remoteFulltextText.setText(gs.getRemoteFulltext());
            remoteImagePathText.setText(gs.getRemoteImagePath());
            remoteIndexPageText.setText(gs.getRemoteIndexPage());
            remoteOpfText.setText(gs.getRemoteOpf());
            useChapterContextBox.setSelected(gs.getUseChapterContext());
            useCoverPathBox.setSelected(gs.getUseCoverPath());
            useGenerateContextPageBox.setSelected(gs.getUseGenerateContextPage());
            useGenerateFulltextBox.setSelected(gs.getUseGenerateFulltext());
            useGenerateIndexPageBox.setSelected(gs.getUseGenerateIndexPage());
            useGenerateOpfBox.setSelected(gs.getUseGenerateOpf());
            useGeneratePathBox.setSelected(gs.getUseGeneratePath());
            useHtmlDemoBox.setSelected(gs.getUseHtmlDemo());
            useImagePathBox.setSelected(gs.getUseImagePath());
            useJsContextBox.setSelected(gs.getUseJsContext());
            parametersText.setText(gs.getParameters());
        } catch (Exception ex) {
            Logger.getLogger(GenerateSettingPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        useGenerateIndexPageBox = new javax.swing.JCheckBox();
        useGenerateContextPageBox = new javax.swing.JCheckBox();
        useGenerateFulltextBox = new javax.swing.JCheckBox();
        useGenerateOpfBox = new javax.swing.JCheckBox();
        useChapterContextBox = new javax.swing.JCheckBox();
        useImagePathBox = new javax.swing.JCheckBox();
        useCoverPathBox = new javax.swing.JCheckBox();
        useJsContextBox = new javax.swing.JCheckBox();
        useGeneratePathBox = new javax.swing.JCheckBox();
        useHtmlDemoBox = new javax.swing.JCheckBox();
        generateIndexPageText = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        parametersText = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        prevPageText = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        nextPageText = new javax.swing.JTextField();
        generateContextPageText = new javax.swing.JTextField();
        generateFulltextText = new javax.swing.JTextField();
        generateOpfText = new javax.swing.JTextField();
        chapterContextText = new javax.swing.JTextField();
        imagePathText = new javax.swing.JTextField();
        coverPathText = new javax.swing.JTextField();
        remoteIndexPageText = new javax.swing.JTextField();
        remoteContextPageText = new javax.swing.JTextField();
        remoteFulltextText = new javax.swing.JTextField();
        remoteOpfText = new javax.swing.JTextField();
        remoteChapterContextText = new javax.swing.JTextField();
        remoteImagePathText = new javax.swing.JTextField();
        remoteCoverPathText = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        jLabel1.setFont(new java.awt.Font("宋体", 0, 12));
        jLabel1.setText("硬盘路径");

        jLabel2.setFont(new java.awt.Font("宋体", 0, 12));
        jLabel2.setText("网站路径");

        useGenerateIndexPageBox.setFont(new java.awt.Font("宋体", 0, 12));
        useGenerateIndexPageBox.setText("生成目录页HTML");

        useGenerateContextPageBox.setFont(new java.awt.Font("宋体", 0, 12));
        useGenerateContextPageBox.setText("生成内容页HTML");

        useGenerateFulltextBox.setFont(new java.awt.Font("宋体", 0, 12));
        useGenerateFulltextBox.setText("生成全文阅读");

        useGenerateOpfBox.setFont(new java.awt.Font("宋体", 0, 12));
        useGenerateOpfBox.setText("生成索引文件OPF");

        useChapterContextBox.setFont(new java.awt.Font("宋体", 0, 12));
        useChapterContextBox.setSelected(true);
        useChapterContextBox.setText("章节实际内容");
        useChapterContextBox.setEnabled(false);

        useImagePathBox.setFont(new java.awt.Font("宋体", 0, 12));
        useImagePathBox.setSelected(true);
        useImagePathBox.setText("图片位置");
        useImagePathBox.setEnabled(false);

        useCoverPathBox.setFont(new java.awt.Font("宋体", 0, 12));
        useCoverPathBox.setSelected(true);
        useCoverPathBox.setText("封面位置");
        useCoverPathBox.setEnabled(false);

        useJsContextBox.setFont(new java.awt.Font("宋体", 0, 12));
        useJsContextBox.setText("启用JS调用实际内容");

        useGeneratePathBox.setFont(new java.awt.Font("宋体", 0, 12));
        useGeneratePathBox.setText("启动自定义生成路径");

        useHtmlDemoBox.setFont(new java.awt.Font("宋体", 0, 12));
        useHtmlDemoBox.setText("启动自定义HTML模板");

        parametersText.setColumns(20);
        parametersText.setRows(5);
        jScrollPane1.setViewportView(parametersText);

        jLabel3.setFont(new java.awt.Font("宋体", 0, 12));
        jLabel3.setText("第一页的上一页");

        jLabel4.setFont(new java.awt.Font("宋体", 0, 12));
        jLabel4.setText("最后一页的下一页");

        jButton1.setFont(new java.awt.Font("宋体", 0, 12));
        jButton1.setText("确定");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("宋体", 0, 12));
        jButton2.setText("取消");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(jLabel3))
                    .addComponent(useGenerateIndexPageBox)
                    .addComponent(useGenerateContextPageBox)
                    .addComponent(useCoverPathBox)
                    .addComponent(useHtmlDemoBox)
                    .addComponent(useGeneratePathBox)
                    .addComponent(useJsContextBox)
                    .addComponent(useGenerateFulltextBox)
                    .addComponent(useGenerateOpfBox)
                    .addComponent(useChapterContextBox)
                    .addComponent(useImagePathBox))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(generateIndexPageText, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(generateContextPageText, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(generateFulltextText, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(chapterContextText, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(imagePathText, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(coverPathText, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(generateOpfText)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel2)
                            .addComponent(remoteContextPageText, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                            .addComponent(remoteFulltextText, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                            .addComponent(remoteChapterContextText, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                            .addComponent(remoteImagePathText, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                            .addComponent(remoteCoverPathText, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                            .addComponent(remoteIndexPageText, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                            .addComponent(remoteOpfText)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(prevPageText, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jButton1)
                                .addGap(18, 18, 18)
                                .addComponent(jButton2))
                            .addComponent(nextPageText, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(33, 33, 33))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(useGenerateIndexPageBox)
                            .addComponent(generateIndexPageText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(useGenerateContextPageBox)
                            .addComponent(generateContextPageText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(generateFulltextText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(useGenerateFulltextBox))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(generateOpfText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(useGenerateOpfBox))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(chapterContextText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(useChapterContextBox))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(imagePathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(useImagePathBox))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(coverPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(useCoverPathBox)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(remoteIndexPageText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remoteContextPageText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remoteFulltextText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remoteOpfText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remoteChapterContextText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remoteImagePathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remoteCoverPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, 0, 0, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(useJsContextBox)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(useGeneratePathBox)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(useHtmlDemoBox)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(nextPageText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel4))
                    .addComponent(prevPageText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addGap(32, 32, 32))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        GenerateSetting gs = new GenerateSetting();
        gs.setChapterContext(chapterContextText.getText().trim());
        gs.setCoverPath(coverPathText.getText().trim());
        gs.setGenerateContextPage(generateContextPageText.getText().trim());
        gs.setGenerateFulltext(generateFulltextText.getText().trim());
        gs.setGenerateIndexPage(generateIndexPageText.getText().trim());
        gs.setGenerateOpf(generateOpfText.getText().trim());
        gs.setImagePath(imagePathText.getText().trim());
        gs.setParameters(parametersText.getText().trim());
        gs.setNextPage(nextPageText.getText().trim());
        gs.setPrevPage(prevPageText.getText().trim());
        gs.setRemoteChapterContext(remoteChapterContextText.getText().trim());
        gs.setRemoteContextPage(remoteContextPageText.getText().trim());
        gs.setRemoteCoverPath(remoteCoverPathText.getText().trim());
        gs.setRemoteFulltext(remoteFulltextText.getText().trim());
        gs.setRemoteImagePath(remoteImagePathText.getText().trim());
        gs.setRemoteIndexPage(remoteIndexPageText.getText().trim());
        gs.setRemoteOpf(remoteOpfText.getText().trim());
        gs.setUseChapterContext(useChapterContextBox.isSelected());
        gs.setUseCoverPath(useCoverPathBox.isSelected());
        gs.setUseGenerateContextPage(useGenerateContextPageBox.isSelected());
        gs.setUseGenerateFulltext(useGenerateFulltextBox.isSelected());
        gs.setUseGenerateIndexPage(useGenerateIndexPageBox.isSelected());
        gs.setUseGenerateOpf(useGenerateOpfBox.isSelected());
        gs.setUseGeneratePath(useGeneratePathBox.isSelected());
        gs.setUseHtmlDemo(useHtmlDemoBox.isSelected());
        gs.setUseImagePath(useImagePathBox.isSelected());
        gs.setUseJsContext(useJsContextBox.isSelected());
        try {
            Utility.writeXMLFile("GenerateSetting.xml", gs);
        } catch (Exception ex) {
            Logger.getLogger(GenerateSettingPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField chapterContextText;
    private javax.swing.JTextField coverPathText;
    private javax.swing.JTextField generateContextPageText;
    private javax.swing.JTextField generateFulltextText;
    private javax.swing.JTextField generateIndexPageText;
    private javax.swing.JTextField generateOpfText;
    private javax.swing.JTextField imagePathText;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField nextPageText;
    private javax.swing.JTextArea parametersText;
    private javax.swing.JTextField prevPageText;
    private javax.swing.JTextField remoteChapterContextText;
    private javax.swing.JTextField remoteContextPageText;
    private javax.swing.JTextField remoteCoverPathText;
    private javax.swing.JTextField remoteFulltextText;
    private javax.swing.JTextField remoteImagePathText;
    private javax.swing.JTextField remoteIndexPageText;
    private javax.swing.JTextField remoteOpfText;
    private javax.swing.JCheckBox useChapterContextBox;
    private javax.swing.JCheckBox useCoverPathBox;
    private javax.swing.JCheckBox useGenerateContextPageBox;
    private javax.swing.JCheckBox useGenerateFulltextBox;
    private javax.swing.JCheckBox useGenerateIndexPageBox;
    private javax.swing.JCheckBox useGenerateOpfBox;
    private javax.swing.JCheckBox useGeneratePathBox;
    private javax.swing.JCheckBox useHtmlDemoBox;
    private javax.swing.JCheckBox useImagePathBox;
    private javax.swing.JCheckBox useJsContextBox;
    // End of variables declaration//GEN-END:variables
}
